/********************************************************************************************************
 * PROGRAM      : TM
 * DATE - TIME  : Friday 04 August 2006 - 19h18
 * AUTHOR       :  (  )
 * FILENAME     : main.cpp
 * LICENSE      : 
 * COMMENTARY   : 
 ********************************************************************************************************/
#include <QCoreApplication>
#include <QtDebug>
#include "mcamcon.h"
using namespace TM;
int main( int argc, char ** argv )
{
    QString sPort,
            dataServer,
            viewServer,
            temp;
    quint16 dataPort=0,
            viewPort=0;

	QCoreApplication app( argc, argv );
    qDebug()<<argc;   
    for(int i=1; i <= argc ; i+=2)
    {
     temp = argv[i];
     qDebug()<<"argc["<<i<<"]:"<<temp<<" argc["<<i<<"+1]:"<<argv[i+1];
     if(temp == "-dev")
      sPort = argv[i+1];
     if(temp == "-dataPort")
     {
      temp = argv[i+1];
      dataPort = temp.toUInt();
      
     } 
     if(temp == "-viewPort")
     {
      temp = argv[i+1];
      viewPort = temp.toUInt();
      
     }
     if(temp == "-dataServer")
      dataServer = argv[i+1];
     
     if(temp == "-viewServer")
      viewServer = argv[i+1];
     

    }
    qDebug()<<"sPort"<<sPort;
    qDebug()<<"dataPort="<<dataPort;
    qDebug()<<"viewPort"<<viewPort;
    qDebug()<<"dataServer"<<dataServer;
    qDebug()<<"viewServer"<<viewServer; 
    if(sPort.isEmpty()|| dataPort==0||viewPort==0||dataServer.isEmpty()||viewServer.isEmpty() )
     {
      qWarning("one or more of the following is missing: -dev [serial port] -dataPort [dataPort] -viewPort [viewPort] -dataServer [dataServer] -viewServer [viewServer]");
      qDebug()<<sPort<<" "<<dataPort<<" "<<viewPort<<" "<<dataServer<<" "<<viewServer;
      if(sPort.isEmpty())
       exit(0);
     qDebug()<<"contenue";  
     } 
	MCamCon camcon(sPort, dataPort, viewPort, dataServer, viewServer);
    camcon.start();
	//
	return app.exec();
}
